<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.Date" %>
<%@ page import="studentinformationmanagementsystem.entity.Teacher" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<%
		Integer teacherid=0;
		String teachername = "";
		String idnumber = "";
		String sex = "";
		String phone = "";
		String politicsstatus = "";
		String nation = "";
		String photograph = "";
		String mailbox = "";
		Date birthdate = null;
		String nativeplace = "";
		String homeaddress = "";
		String teachingage = "";
		String education = "";
		Date entrytime = null;
		String individualresume = "";
		String Teachersworknumber = "";
		String password = "";
//				Student student1=(Student)request.getAttribute("studentinfo");
		Teacher teacher=(Teacher) request.getSession().getAttribute("teacherinfo");
		if(teacher!=null){
			teacherid=teacher.getTeacherid();
			teachername=teacher.getTeachername();
			idnumber=teacher.getIdnumber();
			sex=teacher.getSex();
			phone=teacher.getPhone();
			politicsstatus=teacher.getPoliticsstatus();
			nation=teacher.getNation();
			photograph=teacher.getPhotograph();
			mailbox=teacher.getMailbox();
			birthdate=teacher.getBirthdate();
			nativeplace=teacher.getNativeplace();
			homeaddress=teacher.getHomeaddress();
			teachingage=teacher.getTeachingage();
			education=teacher.getEducation();
			entrytime=teacher.getEntrytime();
			individualresume=teacher.getIndividualresume();
			Teachersworknumber=teacher.getTeachersworknumber();
			password=teacher.getPassword();
		}
//		assert teacher != null;
	%>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
	<title>Preskool - Teachers</title>

	<!-- Favicon -->
	<link rel="shortcut icon" href="assets/img/favicon.png">

	<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,500;0,600;0,700;1,400&display=swap">

	<!-- Bootstrap CSS -->
	<link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css">

	<!-- Fontawesome CSS -->
	<link rel="stylesheet" href="assets/plugins/fontawesome/css/fontawesome.min.css">
	<link rel="stylesheet" href="assets/plugins/fontawesome/css/all.min.css">
	<script src="../../js/sweetalert.min.js" type="text/javascript"></script>
	<script src="../../js/jquery-1.11.3.min.js"></script>
	<!-- Main CSS -->
	<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>

<!-- Main Wrapper -->
<div class="main-wrapper">

	<!-- Header -->
	<!--页面头部 -->
	<div class="header">

		<!-- Logo -->
		<div class="header-left">
			<a href="index.html" class="logo">
				<img src="assets/img/logo.png" alt="Logo">
			</a>
			<a href="index.html" class="logo logo-small">
				<img src="assets/img/logo-small.png" alt="Logo" width="30" height="30">
			</a>
		</div>
		<!-- /Logo -->

		<a href="javascript:void(0);" id="toggle_btn">
			<i class="fas fa-align-left"></i>
		</a>

		<!-- Search Bar -->
		<div class="top-nav-search">
			<form>
				<input type="text" class="form-control" placeholder="搜索">
				<button class="btn" type="submit"><i class="fas fa-search"></i></button>
			</form>
		</div>
		<!-- /Search Bar -->

		<!-- Mobile Menu Toggle -->
		<a class="mobile_btn" id="mobile_btn">
			<i class="fas fa-bars"></i>
		</a>
		<!-- /Mobile Menu Toggle -->

		<!-- Header Right Menu -->
		<ul class="nav user-menu">

			<!-- Notifications -->
			<li class="nav-item dropdown noti-dropdown">
				<a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown">
					<i class="far fa-bell"></i> <span class="badge badge-pill">3</span>
				</a>
				<div class="dropdown-menu notifications">
					<div class="topnav-dropdown-header">
						<span class="notification-title">通知</span>
						<a href="javascript:void(0)" class="clear-noti"> 清除</a>
					</div>
					<div class="noti-content">
						<ul class="notification-list">
							<li class="notification-message">
								<a href="#">
									<div class="media">
												<span class="avatar avatar-sm">
													<img class="avatar-img rounded-circle" alt="User Image" src="assets/img/profiles/avatar-02.jpg">
												</span>
										<div class="media-body">
											<p class="noti-details"><span class="noti-title">Carlson Tech</span> has approved <span class="noti-title">your estimate</span></p>
											<p class="noti-time"><span class="notification-time">4 mins ago</span></p>
										</div>
									</div>
								</a>
							</li>
							<li class="notification-message">
								<a href="#">
									<div class="media">
												<span class="avatar avatar-sm">
													<img class="avatar-img rounded-circle" alt="User Image" src="assets/img/profiles/avatar-11.jpg">
												</span>
										<div class="media-body">
											<p class="noti-details"><span class="noti-title">International Software Inc</span> has sent you a invoice in the amount of <span class="noti-title">$218</span></p>
											<p class="noti-time"><span class="notification-time">6 mins ago</span></p>
										</div>
									</div>
								</a>
							</li>
							<li class="notification-message">
								<a href="#">
									<div class="media">
												<span class="avatar avatar-sm">
													<img class="avatar-img rounded-circle" alt="User Image" src="assets/img/profiles/avatar-17.jpg">
												</span>
										<div class="media-body">
											<p class="noti-details"><span class="noti-title">John Hendry</span> sent a cancellation request <span class="noti-title">Apple iPhone XR</span></p>
											<p class="noti-time"><span class="notification-time">8 mins ago</span></p>
										</div>
									</div>
								</a>
							</li>
							<li class="notification-message">
								<a href="#">
									<div class="media">
												<span class="avatar avatar-sm">
													<img class="avatar-img rounded-circle" alt="User Image" src="assets/img/profiles/avatar-13.jpg">
												</span>
										<div class="media-body">
											<p class="noti-details"><span class="noti-title">Mercury Software Inc</span> added a new product <span class="noti-title">Apple MacBook Pro</span></p>
											<p class="noti-time"><span class="notification-time">12 mins ago</span></p>
										</div>
									</div>
								</a>
							</li>
						</ul>
					</div>
					<div class="topnav-dropdown-footer">
						<a href="#">View all Notifications</a>
					</div>
				</div>
			</li>
			<!-- /Notifications -->

			<!-- User Menu -->
			<li class="nav-item dropdown has-arrow">
				<a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown">
					<span class="user-img"><img class="rounded-circle" src="assets/img/profiles/avatar-01.jpg" width="31" alt="Ryan Taylor"></span>
				</a>
				<div class="dropdown-menu">
					<div class="user-header">
						<div class="avatar avatar-sm">
							<img src="assets/img/profiles/avatar-01.jpg" alt="User Image" class="avatar-img rounded-circle">
						</div>
						<div class="user-text">
							<h6>Ryan Taylor</h6>
							<p class="text-muted mb-0">Administrator</p>
						</div>
					</div>
					<a class="dropdown-item" href="profile.html">我的资料</a>
					<a class="dropdown-item" href="inbox.html">邮箱</a>
					<a class="dropdown-item" href="../log/login.html">注销</a>
				</div>
			</li>
			<!-- /User Menu -->

		</ul>
		<!-- /Header Right Menu -->

	</div>
	<!-- /Header -->

	<!-- Sidebar -->
	<div class="sidebar" id="sidebar">
		<div class="sidebar-inner slimscroll">
			<div id="sidebar-menu" class="sidebar-menu">
				<ul>
					<li class="menu-title">
						<span>主菜单</span>
					</li>
					<li >
						<a href="index.html"><i class="fas fa-th-large"></i> <span>首页</span></a>
					</li>
					<li class="submenu">
						<a href="#"><i class="fas fa-user-graduate"></i> <span> 学生管理</span> <span class="menu-arrow"></span></a>
						<ul>
							<li><a href="students.jsp">查看所有学生</a></li>
<%--							<li><a href="student-details.jsp">查看学生详情</a></li>--%>
<%--							<li><a href="add-student.html">添加学生信息</a></li>--%>
<%--							<li><a href="edit-student.jsp">修改学生信息</a></li>--%>
						</ul>
					</li>
					<li class="submenu active">
						<a href="#"><i class="fas fa-chalkboard-teacher"></i> <span> 教师管理</span> <span class="menu-arrow"></span></a>
						<ul>
							<li><a href="teachers.jsp" >查看所有教师</a></li>
<%--							<li><a href="teacher-details.jsp">查看教师详情</a></li>--%>
<%--							<li><a href="add-teacher.html" >添加教师信息</a></li>--%>
<%--							<li><a href="edit-teacher.jsp" class="active">修改教师信息</a></li>--%>
						</ul>
					</li>
<%--					<li class="submenu">--%>
<%--						<a href="#"><i class="fas fa-building"></i> <span> 院系管理</span> <span class="menu-arrow"></span></a>--%>
<%--						<ul>--%>
<%--							<li><a href="departments.html">查看所有院系</a></li>--%>
<%--							<li><a href="add-department.html">添加院系信息</a></li>--%>
<%--							<li><a href="edit-department.html">修改院系信息</a></li>--%>
<%--						</ul>--%>
<%--					</li>--%>
					<li class="submenu">
						<a href="#"><i class="fas fa-book-reader"></i> <span> 课程管理</span> <span class="menu-arrow"></span></a>
						<ul>
							<li><a href="subjects.jsp">查看所有课程</a></li>
<%--							<li><a href="add-subject.jsp">添加课程信息</a></li>--%>
<%--							<li><a href="edit-subject.jsp">修改课程信息</a></li>--%>
						</ul>
					</li>
<%--					<li class="submenu">--%>
<%--						<a href="#"><i class="fas fa-user-graduate"></i> <span> 班级管理</span> <span class="menu-arrow"></span></a>--%>
<%--						<ul>--%>
<%--							<li><a href="clazz.html">查看所有班级</a></li>--%>
<%--							<li><a href="add-clazz.html">添加班级信息</a></li>--%>
<%--							<li><a href="edit-clazz.html">修改班级信息</a></li>--%>
<%--						</ul>--%>
<%--					</li>--%>
<%--					<li class="submenu">--%>
<%--						<a href="#"><i class="fas fa-building"></i> <span> 专业管理</span> <span class="menu-arrow"></span></a>--%>
<%--						<ul>--%>
<%--							<li><a href="major.html">查看所有专业</a></li>--%>
<%--							<li><a href="add-major.html">添加专业信息</a></li>--%>
<%--							<li><a href="edit-major.html">修改专业信息</a></li>--%>
<%--						</ul>--%>
<%--					</li>--%>
<%--					<li class="submenu ">--%>
<%--						<a href="#"><i class="fas fa-chalkboard-teacher"></i> <span> 选课管理</span> <span class="menu-arrow"></span></a>--%>
<%--						<ul>--%>
<%--							<li><a href="course.html" >查看所有选修课</a></li>--%>
<%--							<li><a href="add-course.html">添加选修课信息</a></li>--%>
<%--							<li><a href="edit-course.html">修改选修课信息</a></li>--%>
<%--						</ul>--%>
<%--					</li>--%>


					<li class="submenu ">
						<a href="#"><i class="fas fa-chalkboard-teacher"></i> <span>课程表管理</span> <span class="menu-arrow"></span></a>
						<ul>
							<li><a href="quall-class-schedule.jsp">查看课程表信息</a></li>
<%--							<li><a href="add-class-schedue.html">添加课程表信息</a></li>--%>
<%--							<li><a href="edit-class-schedule.html">修改课程表信息</a></li>--%>
						</ul>
					</li>

				</ul>
			</div>
		</div>
	</div>
	<!-- /Sidebar -->

	<!-- Page Wrapper -->
	<div class="page-wrapper">
		<div class="content container-fluid">

			<!-- Page Header -->
			<div class="page-header">
				<div class="row align-items-center">
					<div class="col">
						<h3 class="page-title">修改教师信息</h3>
						<ul class="breadcrumb">
							<li class="breadcrumb-item"><a href="teachers.jsp">教师列表</a></li>
							<li class="breadcrumb-item active">修改教师信息</li>
						</ul>
					</div>
				</div>
			</div>
			<!-- /Page Header -->

			<div class="row">
				<div class="col-sm-12">

					<div class="card">
						<div class="card-body">

							<form method="post" enctype="multipart/form-data" id="form2">
								<div class="row">
									<input type="hidden" name="action" id="action" value="update">
									<div class="col-12">
										<h5 class="form-title"><span>基础信息</span></h5>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>姓名</label>
											<label>
												<span id="teachernameSpan" ></span>
												<input type="text" class="form-control" name="teachername" id="teachername" value="<%=teachername%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>性别</label>
											<label>
												<span id="sexSpan" ></span>
												<select class="form-control" name="sex" id="sex">
													<option><%=sex%></option>
													<%--													<option>选择性别</option>--%>
													<option>男</option>
													<option>女</option>
												</select>
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>出生日期</label>
											<label>
												<span id="birthSpan" ></span>
												<input type="date" class="form-control" name="birthdate" id="birthdate" value="<%=birthdate%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>籍贯</label>
											<label>
												<span id="nativeplaceSpan" ></span>
												<input type="text" class="form-control" name="nativeplace" id="nativeplace" value="<%=nativeplace%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>入职时间</label>
											<label>
												<span id="entrytimeSpan" ></span>
												<input type="date" class="form-control" name="entrytime" id="entrytime" value="<%=entrytime%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>家庭住址</label>
											<label>
												<span id="homeaddressSpan" ></span>
												<input class="form-control" type="text" name="homeaddress" id="homeaddress" value="<%=homeaddress%>">
											</label>
										</div>
									</div>

									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>教龄</label>
											<label>
												<span id="teachingageSpan" ></span>
												<input class="form-control" type="text" name="teachingage" id="teachingage" value="<%=teachingage%>">
											</label>
										</div>
									</div>

									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>学历</label>
											<label>
												<span id="educationSpan" ></span>
												<select class="form-control" name="education" id="education">
													<option><%=education%></option>
													<%--													<option>选择学历</option>--%>
													<option>博士研究生</option>
													<option>硕士研究生</option>
													<option>大学本科</option>
													<option>大学专科</option>
												</select>
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>政治面貌</label>
											<label>
												<span id="politicsstatusSpan" ></span>
												<input type="text" class="form-control" name="politicsstatus" id="politicsstatus" value="<%=politicsstatus%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>身份证号码</label>
											<label>
												<span id="idnumberSpan" ></span>
												<input type="text" class="form-control" name="idnumber" id="idnumber" value="<%=idnumber%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>电话</label>
											<label>
												<span id="phoneSpan" ></span>
												<input type="text" class="form-control" name="phone" id="phone" value="<%=phone%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>民族</label>
											<label>
												<span id="nationSpan" ></span>
												<input type="text" class="form-control" name="nation" id="nation" value="<%=nation%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>个人照片</label>
											<span id="photographSpan" ></span>
<%--											<input type="file" class="form-control" name="photograph" value="<%=photograph%>">--%>
											<input type="file" class="form-control" name="photograph" id="photograph" onchange="upfile()" value="<%=photograph%>">
											<input type="hidden" name="filename" id="filename">
											<img id="img" src="/studentinformationmanagementsystems/studentinformationmanagement/<%=photograph%>" width="80px"height="80px" alt=""/>
											<br/>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>邮箱</label>
											<label>
												<span id="mailboxSpan" ></span>
												<input type="email" class="form-control" name="mailbox" id="mailbox" value="<%=mailbox%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>个人简介</label>
											<label>
												<span id="individualresumeSpan" ></span>
												<input type="text" class="form-control" name="individualresume" id="individualresume" value="<%=individualresume%>">
											</label>
										</div>
									</div>
									<div class="col-12">
										<h5 class="form-title"><span>登录信息</span></h5>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>登录账号</label>
											<label>
												<span id="TeachersworknumberSpan" ></span>
												<input type="text" class="form-control" name="Teachersworknumber" id="Teachersworknumber" value="<%=Teachersworknumber%>">
											</label>
										</div>
									</div>
									<div class="col-12 col-sm-6">
										<div class="form-group">
											<label>登录密码</label>
											<label>
												<span id="passwordSpan" ></span>
												<input type="text" class="form-control" name="password" id="password" value="<%=password%>">
											</label>
										</div>
									</div>

									<div class="col-12">
										<button type="button" class="btn btn-primary btn-teacher-update" id="btn-teacher-update">提交</button>
									</div>
								</div>
							</form>
						</div>
					</div>

				</div>
			</div>
		</div>

	</div>
	<!-- /Page Wrapper -->

</div>
<!-- /Main Wrapper -->

<!-- jQuery -->
<script src="./assets/js/jquery-3.5.1.min.js"></script>
<script src="../../js/jquery-1.11.3.min.js"></script>
<!-- Bootstrap Core JS -->
<script src="./assets/js/popper.min.js"></script>
<script src="./assets/plugins/bootstrap/js/bootstrap.min.js"></script>

<!-- Slimscroll JS -->
<script src="./assets/plugins/slimscroll/jquery.slimscroll.min.js"></script>

<!-- Custom JS -->
<script src="assets/js/script.js"></script>
<script type="text/javascript">
	$(function () {
		//失去焦点时自动匹配正确规范的姓名
		$('#teachername').blur(function () {
			var teachername = $('#teachername').val()
			var namePatt = /^([\u4e00-\u9fa5]+|([a-zA-Z]+\s?)+)$/;
			if (!namePatt.test(teachername)) {
				// alert("格式错误，请输入正确的姓名")
				$('#teachernameSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的姓名"
			} else {
				// alert("格式正确")
				$('#teachernameSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})

		//失去焦点时自动匹配正确规范的老师工号
		$('#Teachersworknumber').blur(function () {
			var teacherid = $('#Teachersworknumber').val()
			var namePatt = /^\d{11}$/;
			if (!namePatt.test(teacherid)) {
				// alert("格式错误，请输入正确的姓名")
				$('#TeachersworknumberSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的教师工号,由11位数组成"
			} else {
				// alert("格式正确")
				$('#TeachersworknumberSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的身份证号
		$('#idnumber').blur(function () {
			var teacherid = $('#idnumber').val()
			var namePatt = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
			if (!namePatt.test(teacherid)) {
				// alert("格式错误，请输入正确的姓名")
				$('#idnumberSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的身份证号"
			} else {
				// alert("格式正确")
				$('#idnumberSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的学历
		$('#education').blur(function () {
			var teacherid = $('#education').val()
			var namePatt = /^大学专科$|^大学本科$|^硕士研究生$|^博士研究生$/;
			if (!namePatt.test(teacherid)) {
				// alert("格式错误，请输入正确的性别")
				$('#educationSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">"
			} else {
				// alert("格式正确")
				$('#educationSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的民族
		$('#nation').blur(function () {
			var teacherid = $('#nation').val()
			var namePatt = /[\u4e00-\u9fa5]+/;
			if (!namePatt.test(teacherid)) {
				// alert("格式错误，请输入正确的姓名")
				$('#nationSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的民族"
			} else {
				// alert("格式正确")
				$('#nationSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的手机号
		$('#phone').blur(function () {
			var teacherid = $('#phone').val()
			var namePatt = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
			if (!namePatt.test(teacherid)) {
				$('#phoneSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的手机号"
			} else {
				// alert("格式正确")
				$('#phoneSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的邮箱
		$('#mailbox').blur(function () {
			var teacherid = $('#mailbox').val()
			var namePatt = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
			if (!namePatt.test(teacherid)) {
				$('#mailboxSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的邮箱"
			} else {
				// alert("格式正确")
				$('#mailboxSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的政治面貌
		$('#politicsstatus').blur(function () {
			var teacherid = $('#politicsstatus').val()
			var namePatt = /[\u4e00-\u9fa5]+/;
			if (!namePatt.test(teacherid)) {
				$('#politicsstatusSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的政治面貌"
			} else {
				// alert("格式正确")
				$('#politicsstatusSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的家庭住址
		$('#homeaddress').blur(function () {
			var teacherid = $('#homeaddress').val()
			var namePatt = /^(?=.*?[\u4E00-\u9FA5])[\d\u4E00-\u9FA5]+/;
			if (!namePatt.test(teacherid)) {
				$('#homeaddressSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的家庭住址"
			} else {
				// alert("格式正确")
				$('#homeaddressSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的籍贯
		$('#nativeplace').blur(function () {
			var teacherid = $('#nativeplace').val()
			var namePatt = /^(?=.*?[\u4E00-\u9FA5])[\d\u4E00-\u9FA5]+/;
			if (!namePatt.test(teacherid)) {
				$('#nativeplaceSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的籍贯"
			} else {
				// alert("格式正确")
				$('#nativeplaceSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的密码，密码至少包含 数字和英文，长度6-20
		$('#password').blur(function () {
			var teacherid = $('#password').val()
			var namePatt = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;
			if (!namePatt.test(teacherid)) {
				$('#passwordSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">密码至少包含 数字和英文，长度6-20"
			} else {
				// alert("格式正确")
				$('#passwordSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的教龄
		$('#teachingage').blur(function () {
			var teacherid = $('#teachingage').val()
			var namePatt = /^[0-9]{1,2}$/;
			if (!namePatt.test(teacherid)) {
				$('#teachingageSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">请输入正确的教龄"
			} else {
				// alert("格式正确")
				$('#teachingageSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的日期
		$('#birthdate').blur(function () {
			var teacherid = $('#birthdate').val()
			var namePatt = /\d{4}-\d{2}-\d{2}/;
			if (!namePatt.test(teacherid)) {
				// alert("格式错误，请输入正确的姓名")
				$('#birthSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">"
			} else {
				// alert("格式正确")
				$('#birthSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配正确规范的日期
		$('#entrytime').blur(function () {
			var teacherid = $('#entrytime').val()
			var namePatt = /\d{4}-\d{2}-\d{2}/;
			if (!namePatt.test(teacherid)) {
				// alert("格式错误，请输入正确的姓名")
				$('#entrytimeSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">"
			} else {
				// alert("格式正确")
				$('#entrytimeSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配图片是否为空
		$('#photograph').blur(function () {
			var teacherid = $('#photograph').val()
			if (teacherid == null || teacherid == '') {
				// alert("格式错误，请输入正确的姓名")
				$('#photographSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">图片不能为空"
			} else {
				// alert("格式正确")
				$('#photographSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		//失去焦点时自动匹配个人简介是否为空
		$('#individualresume').blur(function () {
			var teacherid = $('#individualresume').val()
			if (teacherid == null || teacherid == '') {
				// alert("格式错误，请输入正确的姓名")
				$('#individualresumeSpan')[0].innerHTML = "<img src=\"../../img/wrong.png\" width=\"18\"height=\"18\">个人简介不能为空"
			} else {
				// alert("格式正确")
				$('#individualresumeSpan')[0].innerHTML = "<img src=\"../../img/right.png\" width=\"18\"height=\"18\">"
			}
		})
		$(function () {
			//添加教师信息
			$('#btn-teacher-update').click(function () {
				var filename =$('#filename').val();
				if (filename==null||filename==''){
					$('#filename').val("<%=photograph%>")
				}
				var teachername1 = $('#teachername').val()
				var Teachersworknumber1 = $('#Teachersworknumber').val()
				var idnumber1 = $('#idnumber').val()
				var education1 = $('#education').val()
				var nation1 = $('#nation').val()
				var phone1 = $('#phone').val()
				var mailbox1 = $('#mailbox').val()
				var politicsstatus1 = $('#politicsstatus').val()
				var homeaddress1 = $('#homeaddress').val()
				var nativeplace1 = $('#nativeplace').val()
				var password1 = $('#password').val()
				var teachingage1 = $('#teachingage').val()
				var entrytime1 = $('#entrytime').val()
				var birthdate1 = $('#birthdate').val()
				// var photograph1 = $('#photograph').val()
				var individualresume1 = $('#individualresume').val()


				console.log(teachername1)
				console.log(Teachersworknumber1)
				console.log(idnumber1)
				console.log(education1)
				console.log(nation1)
				console.log(phone1)
				console.log(mailbox1)
				console.log(politicsstatus1)
				console.log(homeaddress1)
				console.log(nativeplace1)
				console.log(password1)
				console.log(teachingage1)
				console.log(entrytime1)
				console.log(birthdate1)
				// console.log(photograph1)
				console.log(individualresume1)


				var namePatt = /^([\u4e00-\u9fa5]+|([a-zA-Z]+\s?)+)$/;
				var namePatt1 = /^\d{11}$/;
				var namePatt2 = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
				var namePatt3 = /^大学专科$|^大学本科$|^硕士研究生$|^博士研究生$/;
				var namePatt4 = /[\u4e00-\u9fa5]+/;
				var namePatt5 = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
				var namePatt6 = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
				var namePatt7 = /[\u4e00-\u9fa5]+/;
				var namePatt8 = /^(?=.*?[\u4E00-\u9FA5])[\d\u4E00-\u9FA5]+/;
				var namePatt9 = /^(?=.*?[\u4E00-\u9FA5])[\d\u4E00-\u9FA5]+/;
				var namePatt10 = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;
				var namePatt11 = /^[0-9]{1,2}$/;
				var namePatt12 = /\d{4}-\d{2}-\d{2}/;
				var namePatt13 = /\d{4}-\d{2}-\d{2}/;
				// $('#form1').serialize();
				if (teachername1 == "" || $.trim(teachername1) == null || $.trim(teachername1) === '') {
					swal({
						title: "添加提示信息",
						type: "error",
						text: "姓名不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});
					return false;
				} else if (!namePatt.test(teachername1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "姓名格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				}
				if (Teachersworknumber1 == "" || $.trim(Teachersworknumber1) == null || $.trim(Teachersworknumber1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "教师工号（登入账号）不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt1.test(Teachersworknumber1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "教师工号（登入账号）格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (idnumber1 == "" || $.trim(idnumber1) == null || $.trim(idnumber1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "身份证号码不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt2.test(idnumber1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "身份证号码格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (education1 == "" || $.trim(education1) == null || $.trim(education1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "学历不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt3.test(education1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "学历格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (nation1 == "" || $.trim(nation1) == null || $.trim(nation1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "民族不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt4.test(nation1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "民族格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (phone1 == "" || $.trim(phone1) == null || $.trim(phone1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "手机号不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt5.test(phone1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "手机号格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (mailbox1 == "" || $.trim(mailbox1) == null || $.trim(mailbox1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "邮箱不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt6.test(mailbox1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "邮箱格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (politicsstatus1 == "" || $.trim(politicsstatus1) == null || $.trim(politicsstatus1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "政治面貌不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt7.test(politicsstatus1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "政治面貌格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (homeaddress == "" || $.trim(homeaddress1) == null || $.trim(homeaddress1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "家庭住址不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt8.test(homeaddress1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "家庭住址格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (nativeplace1 == "" || $.trim(nativeplace1) == null || $.trim(nativeplace1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "籍贯不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt9.test(nativeplace1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "籍贯格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (password1 == "" || $.trim(password1) == null || $.trim(password1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "密码不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt10.test(password1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "密码格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (teachingage1 == "" || $.trim(teachingage1) == null || $.trim(teachingage1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "教龄不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt11.test(teachingage1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "教龄格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (entrytime1 == "" || $.trim(entrytime1) == null || $.trim(entrytime1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "入职时间不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt12.test(entrytime1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "入职时间格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (birthdate1 == "" || $.trim(birthdate1) == null || $.trim(birthdate1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "出生日期不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				} else if (!namePatt13.test(birthdate1)) {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "出生日期格式不正确！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				// } else if (photograph1 == "" || $.trim(photograph1) == null || $.trim(photograph1) == '') {
				//
				// 	swal({
				// 		title: "添加提示信息",
				// 		type: "error",
				// 		text: "图片不能为空！",
				// 		confirmButtonText: "确定",
				// 		closeOnConfirm: false
				// 	});
				//
				// 	return false;
				} else if (individualresume1 == "" || $.trim(individualresume1) == null || $.trim(individualresume1) == '') {

					swal({
						title: "添加提示信息",
						type: "error",
						text: "个人简介不能为空！",
						confirmButtonText: "确定",
						closeOnConfirm: false
					});

					return false;
				}
				$.ajax({
					// url:'./teacher.do?action=insert',
					url: './teacher.do',
					// dataType:'text',
					data: $('#form2').serialize(),
					type: 'POST',
					success: function (data) {
						console.log(data)
						if (data == 1) {
							swal({
								title: '添加成功',
								icon: 'success',
								text: '添加成功',
								button: {
									text: "确认",
									value: true,
								}
							}).then(function (isOk) {
								if (isOk) {
									location.href = './teacher.do?action=queryAll';
								}
							})
						} else {
							swal({
								title: '添加失败',
								icon: 'warning',
								text: '添加失败，请重新输入',
								button: {
									text: "确认",
									value: true,
								}
							}).then(function (isok) {
								if (isok) {
									location.href = './add-teacher.html'
								}
							})
						}
					}
				})
			})
		})
	})
	//上传图片
	function upfile() {
		var file = $('#photograph')[0].files[0];
		var formData = new FormData();//必须使用FormData表达上传数据
		formData.append("file", file);
		$.ajax({
			method: "post",
			url: "./upload.do",
			data: formData,
			processData: false,//禁止类型转换//必须false才会避开jQuery对 formdata 的默认处理
			contentType: false,//必须false才会自动加上正确的Content-Type
			dataType: "text",
			success: function (data) {
				console.log("我碰见来了");
				console.log(data)
				$('#img').attr('src', '/studentinformationmanagementsystems/studentinformationmanagement/' + data);
				$('input[name=filename]').val(data);
			},
			error: function (err) {
				console.log("error:" + err);
			}
		})
	}
</script>
</body>
</html>